package net.database.model.domain

class Hero {

    static constraints = {
		name		blank: false
		gender		inList: ["Male", "Female"]
		items		validator: {val ->
			def valid = true
			val.each { elem ->
				if (elem.itemType.concurrentNumber != val.count{ it.itemType == elem.itemType })
					valid = false
			}
			if (!valid)
				return ['incorrectNumberOfItems']
		}
    }
	
	static mapping = {
		table 		"hero"
		heroClass	column: "class"
		items		lazy:false
	}
	
	static hasMany = [items: Item]
	
	String name, gender
	HeroClass heroClass
}
